<template>
  <div>
    <orderHeaderVue title="本周数据分析" />
    <StatisticsVue title="Weekly Repoet" :Data="Data" v-if="loading" :key="Commond"/>
  </div>
</template>

<script>
import orderHeaderVue from "../components/orderHeader.vue";
import { defineComponent, onBeforeMount, onMounted, reactive,ref } from "vue";
import StatisticsVue from "../components/Statistics.vue";
import { queryweek } from "../utils/tools";
import { postJSON } from "../utils/request";
export default defineComponent({
  components: {
    orderHeaderVue,
    StatisticsVue,
  },
  setup() {
    let myDate = new Date();

    // 获得这周得日期范围
    const NowDate = queryweek(myDate);

    // loading加载指令
    const loading = ref(false);

    // 这周开始得时间戳
    const WeekStartTime = NowDate.WeekStartDate;

    const Commond = ref(1);

    const Data = reactive({
      DateRange: [NowDate.target[0], NowDate.target[6]],
      StatisticsData: {},
      reglabel:["周天", "周一","周二", "周三", "周四", "周五", "周六" ]
    });

    onMounted(async () => {
      let params = {
        WeekStartTime: WeekStartTime,
        Commond: Commond.value,
      };

      await postJSON("/OneWeek", params).then((res) => {
        console.log(res);
        Data.StatisticsData = res.data;
        loading.value = true;
      });
    });
    
    return {
      Data,
      loading
    };
  },
});
</script>

<style scoped>
</style>